package org.jaronsource.framework.core.web.taglib;

import javax.servlet.ServletContext;
import javax.servlet.jsp.JspException;

import org.jaronsource.framework.core.dao.support.ICommonDao;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class QueryOneTag extends QueryTag {

	private static final long serialVersionUID = 5243805801268475410L;
	
	public int doEndTag() throws JspException {
		
		ServletContext sc = pageContext.getServletContext();
		WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext( sc );

		ICommonDao commonDao = wac.getBean( ICommonDao.class );

		Object result = commonDao.queryOne( jpql, params );
		pageContext.setAttribute( var, result );
		return SKIP_BODY;
	}
	
}